<extend name="base/Base" />
<block name="Style">
<!-- FooTable Plugin CSS -->
		<link rel="stylesheet" type="text/css" href="__ABSOLUTEADMIN__/vendor/plugins/footable/css/footable.core.min.css">
		<!-- Admin Forms CSS -->
		<link rel="stylesheet" type="text/css" href="__ABSOLUTEADMIN__/assets/admin-tools/admin-forms/css/admin-forms.css">
		
</block>
<block name="Topbar">

								
 <!-- Start: Topbar -->
      <header id="topbar" class="ph10">
        <div class="topbar-left">
          <ul class="nav nav-list nav-list-topbar pull-left">
				<li>
              <a href="#" onclick="notice('用户管理中新增用户')"   >新增用户</a>
            </li>
            <li   >
              <a  href="__APP__/Admin/User/Manage.html"   >用户管理</a>
            </li>   
<li   >
              <a href="#"  onclick="notice('用户管理中关联管理')"  >关联管理</a>
            </li> 			
			<li  class="active" >
              <a  href="#"   >{$amdata.nickname}权限</a>
            </li>  			
          </ul>
        </div>
        <!-- <div class="topbar-right hidden-xs hidden-sm">
          <a href="ecommerce_orders.html" class="btn btn-default btn-sm fw600 ml10">
            <span class="fa fa-plus pr5"></span> New Order</a>
          <a href="ecommerce_products.html" class="btn btn-default btn-sm fw600 ml10">
            <span class="fa fa-plus pr5"></span> Add Product</a>
          <a href="ecommerce_customers.html" class="btn btn-default btn-sm fw600 ml10">
            <span class="fa fa-user pr5"></span> Add Customer</a>
        </div> -->
      </header>
      <!-- End: Topbar -->
     <!-- Modal -->
									<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
									  <div class="modal-dialog" role="document">
										<div class="modal-content">
										  <div class="modal-header">
											<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
											<h4 class="modal-title" id="myModalLabel">新增群组</h4>
										  </div>
										  <div class="modal-body">
										  
										   <div class="form-group">
												<label for="exampleInputEmail1">请输入群组名称</label>
												<input  type="text" name="name" id="name" class="form-control"   placeholder="请输入群组名称">
											  </div>
											  <div class="form-group">
												<label for="exampleInputEmail1">请输入群组所属项目</label>
												<select name="pid" id="pid"  class="form-control">
																<volist name="item" id="item">
																<option value="{$item.id}">{$item.name}</option>
																</volist>
															</select>
											  </div>
											  <div class="form-group">
												<label for="exampleInputEmail1">请输入群组项目内排序</label>
												<input type="number" name="sort" id="sort" class="form-control"   placeholder="请输入群组项目内排序">
											  </div>
											  <div class="form-group">
												<label for="exampleInputPassword1">请输入群组说明</label>
												<textarea name="describe"  id="describe" class="form-control" rows="3" placeholder="请输入项目介绍，字数少于140个字。"></textarea>
											  </div>
											  
											
																
						
										  </div>
										  <div class="modal-footer">
											<button type="button" class="btn btn-default" data-dismiss="modal">关闭页面</button>
											<a href="#" class="btn btn-primary" onclick="AJAXCreate()" >新增群组</a>
												
										  </div>
										</div>
									  </div>
									</div>

<script>
						
							
							function AJAXCreate(){  
								var pid = $("#pid").val();
								var sort = $("#sort").val();
								var describe = $("#describe").val();
								var name = $("#name").val();
								
								
								$.ajax({
									type:'POST',
									url:"__APP__/PTCRM/User/Group/Create.html",
									data:{
										"pid": pid,
										"sort": sort,
										"name": name,
										"describe": describe,
										
									},
									success:function(data){								
										if (data == 1) {
											alert('新增成功');
											window.location.reload();
										}else{
											alert(data);
										}
									},
									error:function(){
										alert('未知错误');
									}
								
								});	 
							}  
							
							function AJAXDelete(id){  
								if(confirm('是否确认删除')){
									$.ajax({
										type:'POST',
										url:"__APP__/PTCRM/User/Group/Delete.html",
										data:{
											"id": id,
											
										},
										success:function(data){								
											if (data == 1) {
											alert('删除成功');
											window.location.reload();
											}else{
												alert(data);
											}
										},
										error:function(){
											alert('未知错误');
										}
									
									});	 
								}
							} 
							
							function AJAXOutage(id){  
								if(confirm('是否确认停用')){
									$.ajax({
										type:'POST',
										url:"__APP__/PTCRM/User/Group/Outage.html",
										data:{
											"id": id,
											
										},
										success:function(data){								
											if (data == 1) {
											alert('停用成功');
											window.location.reload();
											}else{
												alert(data);
											}
										},
										error:function(){
											alert('未知错误');
										}
									
									});	 
								}
							} 
							
							function AJAXEnabled(id){  
								if(confirm('是否确认启用')){
									$.ajax({
										type:'POST',
										url:"__APP__/PTCRM/User/Group/Enabled.html",
										data:{
											"id": id,
											
										},
										success:function(data){								
											if (data == 1) {
											alert('启用成功');
											window.location.reload();
											}else{
												alert(data);
											}
										},
										error:function(){
											alert('未知错误');
										}
									
									});	 
								}
							} 
							</script>									
</block>
<block name="Content">

<link rel="stylesheet" type="text/css" href="__ABSOLUTEADMIN__/css/module.css">
  
    
	
	<div class="tab-content" style="padding-left:70px;">
		<!-- 访问授权 -->
		<div class="tab-pane in">
			<form action="__APP__/Admin/User/AuthEdit.html" enctype="application/x-www-form-urlencoded" method="POST" class="form-horizontal auth-form">
				<volist name="node_list" id="node" >
					<dl class="checkmod">
						<dt class="hd" >
							<label class="checkbox" ><input class="auth_rules rules_all" type="checkbox" name="menu[]" value="{$node.id}" {$node.ok}>{$node.name}</label>
						</dt>
						<dd class="bd">
							<present name="node['child']">
							<volist name="node['child']" id="child" >
								<div class="rule_check" style="padding-left:30px;">
									<div>
										<label class="checkbox" >
									   <input class="auth_rules rules_row" type="checkbox" name="menu[]" value="{$child.id}" {$child.ok}/>{$child.name}
										</label>
									</div>
								   <notempty name="child['child']">
									   <span class="divsion">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									   <span class="child_row">
										   <volist name="child['child']" id="op">
											   <label class="checkbox" style="width:130px;">
												   <input class="auth_rules" type="checkbox" name="menu[]" {$op.ok}
												   value="{$op.id}"/>{$op.name}
											   </label>
										   </volist>
									   </span>
								   </notempty>
								</div>
							</volist>
							</present>
						</dd>
					</dl>
				</volist>

				<if condition="$amdata.auth_type eq 2"> 
				<p>选择优先级</p>
				<label class="radio-inline">
				  <input type="radio" name="auth_type" id="auth_type" checked value="2"> 用户优先
				</label>
				<label class="radio-inline">
				  <input type="radio" name="auth_type" id="auth_type" value="1"> 群组优先
				</label>
				
				<else /> 
				
				<p>选择优先级</p>
				<label class="radio-inline">
				  <input type="radio" name="auth_type" id="auth_type"  value="2"> 用户优先
				</label>
				<label class="radio-inline">
				  <input type="radio" name="auth_type" id="auth_type" checked value="1"> 群组优先
				</label>
				
				</if>
				
				
				
				<br>
				<br>
				<br>
				<input type="hidden" name="uid" value="{$uid}" />
				<button type="submit" class="btn submit-btn ajax-post" target-form="auth-form">确 定</button>
				<!-- <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button> -->
			</form>
		</div>

		<!-- 成员授权 -->
		<div class="tab-pane"></div>

		<!-- 分类 -->
		<div class="tab-pane"></div>
	</div>
		
	
</block>
<block name="Script">
	
  <!-- FooTable Plugin -->
  <script src="__ABSOLUTEADMIN__/vendor/plugins/footable/js/footable.all.min.js"></script>
   <!-- FooTable Addon -->
  <script src="__ABSOLUTEADMIN__/vendor/plugins/footable/js/footable.filter.min.js"></script>

 <script type="text/javascript">
  jQuery(document).ready(function() {

 

    // Init FooTable Examples
    $('.footable').footable();


  });
  </script>
  

<script type="text/javascript" charset="utf-8">
    +function($){
        var rules = [{$this_group.rules}];
        $('.auth_rules').each(function(){
            if( $.inArray( parseInt(this.value,10),rules )>-1 ){
                $(this).prop('checked',true);
            }
            if(this.value==''){
                $(this).closest('span').remove();
            }
        });

        //全选节点
        $('.rules_all').on('change',function(){
            $(this).closest('dl').find('dd').find('input').prop('checked',this.checked);
        });
        $('.rules_row').on('change',function(){
            $(this).closest('.rule_check').find('.child_row').find('input').prop('checked',this.checked);
        });

        $('.checkbox').each(function(){
            $(this).qtip({
                content: {
                    text: $(this).attr('title'),
                    title: $(this).text()
                },
                position: {
                    my: 'bottom center',
                    at: 'top center',
                    target: $(this)
                },
                style: {
                    classes: 'qtip-dark',
                    tip: {
                        corner: true,
                        mimic: false,
                        width: 10,
                        height: 10
                    }
                }
            });
        });

        $('select[name=group]').change(function(){
			location.href = this.value;
        });
       
    }(jQuery);
</script>
</block>